home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGNG_C
/
CUG187.LZH
/
CENTER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1985-12-30
|
951b
|
34 lines
#include "stdio.h"
/*@*****************************************************/
/*@ */
/*@ center - center a given string on a given length.*/
/*@ Trims trailing blanks before centering. */
/*@ */
/*@ Usage: center(string, length); */
/*@ NOTE: The string is output to STDOUT. */
/*@ */
/*@*****************************************************/
center(line, linlen)
int linlen;
char *line;
{
char *cp, *wp;
int countr, len;
char c;
len = strlen(trim(line)); /* get non-blank length */
/* output leading blanks */
for (countr=1; countr < (linlen - len)/2; countr++)
putc(' ', stdout);
/* output non-blank chars */
while (c = *cp++)
putc(c, stdout);
putc('\n', stdout); /* end of record */
}